package sfin.controller;

import java.util.List;

import sfin.service.PeriodoService;
import sfin.service.SimulacaoService;
import sfin.swt.data.SimulacaoData;
import sfin.swt.exception.StatizoException;

public class SimulacaoController {

	public String value;
	public String parcelas;
	public int ano;
	public int mes;
	
	private SimulacaoService simulacaoService;
	private PeriodoService periodoService;
	
	public SimulacaoController(SimulacaoService simulacaoService, PeriodoService periodoService) {
		this.simulacaoService = simulacaoService;
		this.periodoService = periodoService;
		loadData();
	}
	
	public void loadData() {
		this.value = "0";
		this.parcelas = "0";
		this.ano = periodoService.getApplicationYear();
	}

	public List<SimulacaoData> getData() throws StatizoException{
		return simulacaoService.calcularSimulacaoAnual(value, parcelas, ano, mes);
	}
	
	public void setValue(String value) {
		this.value = value;
	}
	
	public void setParcelas(String parcelas) {
		this.parcelas = parcelas;
	}
	
	public String[] getYears(){
		return periodoService.getYearNames();
	}
	
	public String[] getMonths(){
		return periodoService.getMonths();
	}
	
	public void setAno(int ano) {
		ano = periodoService.getAt(ano);
	}

	public int getAno() {
		return periodoService.indexOf(ano);
	}
	
	public String[] getMonthNames(){
		return periodoService.getMonths();
	}
	
	public void setMes(int mes) {
		this.mes = mes;
	}
	
	public int getMes() {
		return mes;
	}
	
}
